home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr11 / ddj9304.zip / WAVELET.ZIP / ANALYZER.S < prev    next >
Text File  |  1992-04-17  |  9KB  |  175 lines

  1. #include "dsp_type.h"
  2. #if DSP32
  3. #include "dspregs.h"
  4. #endif
  5.  
  6. .extern DECOMP, DRAWIMAG
  7. .extern WAVEADRS, WAVELVLS, IMAGSHOW, LVLADDRS
  8. .extern SIG_DRAW, DRAW_CNT, H_FILTER, L_FILTER
  9. .extern RST_DATA, IM0_PTRS, IM1_PTRS, IMAGE_0
  10. .extern STACKEND, SIGNALIN, DATA_OUT
  11.  
  12.         /*  ANALYZER
  13.             main control program for the wavelet analyzer
  14.             registers used: r1 r2 r3 r4 r5 r6 r8 r9
  15.                             r11 r12 r13 r14 r15 r16 r17
  16.             accumulators used: a0 a1 a2 a3
  17.         */
  18. .rsect ".bank0"
  19.           dauc = 0x0000;  /* initialize DAU formats */
  20.           r1e = WAVELVLS; /* point to jump address for wavelet filter size */
  21.           r2e = SIGNALIN; /* point to approximation data storage */
  22.           r3 = *r1++;     /* load number of levels in wavelet transform */
  23.           r4 = 8;         /* load number of unit intervals per image */
  24.           r1e = r1 + 2;   /* point to the unit interval count storage */
  25.           *r1++ = r4;     /* store the unit interval count value */
  26.           r4 = r4 - r4;   /* zero the register */
  27.           *r1++ = r4;     /* set active image flag storage to 0 (IMAGE 0) */
  28.           a3 = a3 - a3;   /* intial data value is zero */
  29. #if DSP32C
  30.           r3 = r3 - 1;    /* number of levels in wavelet transform - 1 */
  31.           do 8, r3;       /* repeat next nine instructions r5+1 times */
  32. #else
  33.           r3 = r3 - 2;    /* number of levels in wavelet transform - 2 */
  34. #endif
  35. INITAPPX: *r1++ = r2e;   /* store base address of each approximation level */
  36.           *r2++ = a3 = a3; /* zero storage for approximation level */
  37.           *r2++ = a3 = a3; /* r2 ends up pointing to first location .... */
  38.           *r2++ = a3 = a3; /* in the next approximation level */
  39.           *r2++ = a3 = a3;
  40.           *r2++ = a3 = a3;
  41.           *r2++ = a3 = a3;
  42. #if DSP32C
  43.           nop;
  44.           *r1++ = r2e;    /* store the next location */
  45.           ioc = 0x40987;  /* initialize the serial I/O to the codec */
  46.           r1e = RST_DATA; /* point to reset pointer initialization storage */
  47.           r2e = SIG_DRAW; /* point to signal drawing data sets */
  48.           r3 = 26;        /* integer pointer index, 4 bytes per pointer */
  49.           r2e = r2 + 22;  /* point to bit pointer storage */
  50.           do 3, 7;        /* perform next 4 instructions eight times */
  51.           r4e = *r1++;    /* load initial bit pointer */
  52.           r5e = *r1++;    /* load initial byte column pointer */
  53.           *r2++ = r4;     /* store initial bit pointer */
  54.           *r2++r3 = r5e;  /* store initial byte column pointer */
  55. #else
  56.           if (r3-- >=0) goto INITAPPX; /* repeat for all arrays */
  57.           *r1++ = r2e;   /* store the next location */
  58.           ioc = 0x0987;  /* initialize the serial I/O to the codec */
  59.           r1 = RST_DATA; /* point to reset pointer initialization storage */
  60.           r2 = SIG_DRAW; /* point to signal drawing data storage */
  61.           r3 = 26;       /* integer pointer index, 2 bytes per pointer */
  62.           r2 = r2 + 22;  /* point to bit pointer storage */
  63.           r4 = 6;        /* initialize loop counter for eight loops */
  64. INIT_PTR: r5 = *r1++;    /* load initial bit pointer */
  65.           r6 = *r1++;    /* load initial byte column pointer */
  66.           *r2++ = r5;    /* store initial bit pointer */
  67.           if (r4-- >=0) goto INIT_PTR; /* repeat for all pointers */
  68.           *r2++r3 = r6;  /* store initial byte column pointer */
  69. #endif
  70.           r12e = WAVEADRS; /* load pointer to filter jump address */
  71.           r13e = STACKEND; /* load pointer to top of stack memory */
  72.           r11e = *r12++;   /* load jump address for filter size */
  73.           r16e = *r12++;   /* load coefficient pointer wrap back index */
  74.           r17 = *r12++;    /* load number of levels */
  75.           r15 = *r12;      /* load image data space size / 4 */
  76.           r3e = IMAGE_0;   /* point to the detail level float output */
  77. #if DSP32C
  78.           r15 = r15 - 1;   /* number of data points minus one */
  79.           do 0, r15;       /* repeat next instruction r15+1 times */
  80.           *r3++ = a3 = a3; /* clear four bytes in IMAGE_0 array */
  81. #else
  82.           r15 = r15 - 2;   /* number of data points minus two */
  83. CLR_IMAG: if (r15-- >=0) goto CLR_IMAG; /* repeat until all image cleared */
  84.           *r3++ = a3 = a3; /* clear four bytes in IMAGE_0 array */
  85. #endif
  86.           goto ENTRY_PT;   /* jump to the entry point */
  87.           nop;
  88.  
  89. MAINLOOP: r8 = DATA_OUT;        /* point to output data array */
  90.           r12e = SIG_DRAW;      /* point to signal drawing data sets */
  91.           r9e = DRAW_CNT;       /* point to draw count array */
  92.           a0 = *r8++;           /* load first signal data point */
  93.           r9e = r9 + r15;       /* index into draw count array */
  94.           call DRAWIMAG (r14);  /* draw the first input sample point */
  95.           r9l = *r9;            /* load the draw loop counter */
  96.           r12e = SIG_DRAW;      /* point to signal drawing data sets */
  97. DRWLOOP1: if (ibf) goto SAMPL_IN; /* if true, next sample available */
  98.           nop;
  99.           a0 = *r8++;           /* load data point */
  100.           call DRAWIMAG (r14);  /* draw data point */
  101.           nop;
  102.           if (r9-- >= 0) goto DRWLOOP1; /* repeat for all levels of xfrm */
  103. #if DSP32C
  104.           nop;
  105. #else
  106.           r12 = r12 + 2;        /* point to data set for next level */
  107. #endif
  108. WAITIBF1: if (ibe) goto WAITIBF1; /* wait until next data sample arrives */
  109.           nop;
  110.           goto TEST_LVL;
  111. SAMPL_IN: a3 = float(ibuf);      /* load the new signal sample */
  112. DRWLOOP2: a0 = *r8++;            /* load data point */
  113.           call DRAWIMAG (r14);   /* draw data point */
  114.           nop;
  115.           if (r9-- >= 0) goto DRWLOOP2;
  116. #if DSP32C
  117.           nop;
  118. #else
  119.           r12 = r12 + 2;         /* point to data set for next level */
  120. #endif
  121. TEST_LVL: r15 - 0;               /* test for process of all levels */
  122.           if (ne) goto ENTRY_PT; /* if true, all levels have not been done */
  123.           r12e = IMAGSHOW;       /* point to the unit interval count down */
  124.           nop;
  125.           r3 = *r12++;           /* load the unit interval count down */
  126.           r4 = *r12--;           /* load the image draw flag */
  127.           r3 = r3 - 1;           /* decrement the unit interval count */
  128.           if (ne) goto ENTRY_PT; /* if true, not done with new data set */
  129.           *r12++ = r3;           /* save the new count */
  130.           r3 = 8;                /* reset count to eight unit intervals */
  131.           r12 = r12 - 2;         /* point to unit interval count storage */
  132.           *r12++ = r3;           /* save the reset count */
  133.           pir = r4;              /* interrupt host processor for new image */
  134.           r4 = r4;               /* tickle CAU flags for image set */
  135.           if (ne) goto IM0_NEXT; /* if true, set up for drawing on IMAGE 0 */
  136.           nop;
  137.           r4 = 1;                /* next image displayed is IMAGE 1 */
  138.           goto PNTRINIT;         /* go to image pointer initialization */
  139.           r2e = IM1_PTRS;        /* set up for drawing on IMAGE 1 */
  140.  
  141. IM0_NEXT: r4 = 0;          /* next image displayed is IMAGE 0 */
  142.           r2e = IM0_PTRS;  /* set up for drawing on IMAGE 0 */
  143. PNTRINIT: r1 = SIG_DRAW;   /* point to signal drawing data sets */
  144.           *r12++ = r4;     /* save the image draw flag */
  145.           r1e = r1 + 24;   /* point to byte column pointer storage */
  146. #if DSP32C
  147.           r15e = 28;       /* set up post increment value */
  148.           do 0, 7;         /* perform next instruction eight times */
  149.           a0 = (*r1++r15 = *r2++) + a0; /* moves four bytes at once! */
  150. #else
  151.           r3 = 28;         /* set up post increment value */
  152.           r4 = 6;          /* set up loop counter for eight iterations */
  153. REINIPTR: r5 = *r2++;      /* load image array pointer */
  154.           if (r4-- >= 0) goto REINIPTR; /* repeat for all pointers */
  155.           *r1++r3 = r5;    /* store image array pointer */
  156. #endif
  157. WAIT_PIE: if (pif) goto WAIT_PIE; /* wait for pif flag to be cleared */
  158.           nop;
  159. ENTRY_PT: r3e = SIGNALIN;           /* point to input signal storage array */
  160. WAITIBF2: if (ibe) goto WAITIBF2;   /* wait until next data sample arrives */
  161.           r15 = r17;                /* inititialize the recursion counter */
  162.           *r3++ = a2 = float(ibuf); /* output second data sample first */
  163.           r6e = DATA_OUT;    /* point to output data array */
  164.           *r3 = a3 = a3;     /* output first data sample last */
  165.           *r6++ = a3 = a3;   /* place first sample in data output array */
  166.           *r6++ = a2 = a2;   /* place second sample in data output array */
  167.           r1e = H_FILTER;    /* point to detail filter coefficients */
  168.           r2e = L_FILTER;    /* point to approx. filter coefficients */
  169.           r12e = LVLADDRS;   /* point to data level address pointers */
  170.           a0 = a0 - a0;      /* zero the accumulators */
  171.           call DECOMP (r14); /* start the recursive decomposition */
  172.           a1 = a0;
  173.           goto MAINLOOP;
  174.           nop;
  175.